package com.zengdb.mybatis.service.impl;

import org.apache.ibatis.session.SqlSession;

import com.zengdb.mybatis.dao.EmployeeMapper;
import com.zengdb.mybatis.domain.Employee;
import com.zengdb.mybatis.service.IEmployeeService;
import com.zengdb.mybatis.util.MyBatisUtil;

public class EmployeeServiceImpl implements IEmployeeService{

	@Override
	public void saveOne(Employee emp) {
		SqlSession session = MyBatisUtil.openSession();
		EmployeeMapper dao = session.getMapper(EmployeeMapper.class);
		dao.saveOne(emp);
		session.commit();
		session.close();
	}

	@Override
	public Employee selectOne(Long id) {
		SqlSession session = MyBatisUtil.openSession();
		EmployeeMapper dao = session.getMapper(EmployeeMapper.class);
		Employee emp = dao.selectOne(id);
		session.close();
		return emp;
	}

}
